package com.projectbox.api;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.projectbox.dao.AnnouncementDao;
import com.projectbox.model.Announcement;

@Controller
@RequestMapping("/api/announcement")
public class AnnouncementAPIController {

	private Logger logger = LoggerFactory.getLogger(getClass()); 
	
	private AnnouncementDao announcementDao;
	
	public void setAnnouncementDao(AnnouncementDao announcementDao) {
		this.announcementDao = announcementDao;
	}
	
	@RequestMapping(method = RequestMethod.GET)
	@ResponseBody
    public String displayAnnounments(Model model) {
		List<Announcement> announcements = this.announcementDao.getAnnouncements();
		
		logger.debug("" + announcements);
		
		return announcements.toString();
	}
}
